package com.dimanche.library_base.utils;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import androidx.annotation.NonNull;

/**
 * author : Dimanche
 * date   : 2021/3/5 14:16
 * desc   :
 * version: 1.0
 */
public class AppUtils {
    private static Application sInstance;

    /**
     * 当主工程没有继承BaseApplication时，可以使用setApplication方法初始化BaseApplication
     *
     * @param application
     */
    public static synchronized void setApplication(@NonNull Application application) {
        sInstance = application;
    }

    /**
     * 获得当前app运行的Application
     */
    public static Application getApplication() {
        if (sInstance == null) {
            throw new NullPointerException("please inherit BaseApplication or call setApplication.");
        }
        return sInstance;
    }
}